clear all; clc;RC = 1e-6;
a = [RC 1];
b = [1];
freqs(b, a);


clear all;clc;close all;

RC=1e-6

a=[RC 1 ];b=[1];
Fs=100; Fmax=4e5 ; f=0:Fs:Fmax ;
H=freqs(b,a,2*pi*f)

figure(1);subplot(2,1,1);
plot(f/1e6,20*log10(abs(H)));
subplot(2,1,2);
plot(f/1e6,rad2deg(unwrap(angle(H))))


RC = 1e-6; a = [RC 1]; b = [1];
sys = tf(b,a);
[y,t] = impulse(sys); % Без% сразу построит график
[y,t] =impulse(sys);
figure(2); plot(t, y);
xlabel('t, s'); ylabel('h(t)');
grid on

[z,p,k]=tf2zp(b,a); %Тут что то дофига не понятно%

figure();plot(tf2zp(b,a)); %Тут тоже% Спросить и у Паши.%

clear all; clc

x = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
km = 1:length(x);
for k = km
if k > 1
    y(k) = 0.7*y(k-1) +0.3*x(k)
else
    y(k) = 0.3*x(k);
end
end
figure(4); stem(km,y)

clear all; ; clc
a = [1 -0.7]; b = [0.3];
h = impz(b, a, 15);

figure(5); stem(h);
xlabel('k'); ylabel('h_k'); grid on


clear all; clc
a = [-0.7]; b = [0.3];
xh = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
km = 2:length(xh); h(1) = b(1)*xh(1);
for k = km
h(k) = -a(1)*h(k-1) + b(1)*xh(k);
end
x = [0 0 0 0 0 1 1 1 1 1 1 1 1 1 1];
y = conv(x, h);
xdec = deconv(y, h);
figure(6)
stem(1:length(y), y); hold on
stem(1:length(xdec), xdec, 'r'); hold off
grid on; legend('y', 'x'); xlabel('k')


clear all;clc
a = [-0.7]; b = [0.3];
 xp = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
 km = 1:length(x);
for k = km
 if k > 1
h(k) = -a(1)*h(k-1) + b(1)*xh(k);
 else
 h(k) = b(1)*xh(k);
end
end
T=0.001; f = 0:(1/T/100):(1/T);
z= exp(1i*2*pi*f*T);

H2=0;
    for k = km
    H2 = H2+h(k)+z.^-k;
    end
H1 = 0.3 ./ (1 - 0.7 * z.^-1);
figure(7); plot(f, abs(H1), f, abs(H2), '*')
xlabel('f, Hz'); ylabel('|H|'); grid('on');
